<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2024/10/26
  Time: 10:09
  To change this template use File | Settings | File Templates.
--%>
<%@page import="java.sql.*" %>
<% String id = request.getParameter("stuid");%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>条件查询</title>
    <%ResultSet rs;%>

</head>
<body>
<%
    String dbName = "studb";
    String userName = "root";
    String userPwd = "123456";
    String url = "jdbc:mysql://localhost/" + dbName + "？user=" + userName + "&password=" + userPwd;
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection conn = DriverManager.getConnection(url);
    Statement stmt = conn.createStatement();
    String sql = "select * from student where id=" + id;
    rs = stmt.executeQuery(sql);
%>
<table border="1">
    <th colspan="4" style="font-size: x-large;alignment: center">学生信息表</th>
    <tr style="text-align: center">
        <td>学号</td>
        <td>姓名</td>
        <td>生日</td>
        <td>班级</td>
    </tr>
        <%
        while(rs.next()){  %>
    <tr style="text-align: center">
        <td><%=rs.getString(1) %>
        </td>
        <td><%=rs.getString(2) %>
        </td>
        <td><%=rs.getString("birthday") %>
        </td>
        <td><%=rs.getString("stuclass") %>
        </td>
    </tr>
        <% }%>
    }
        <%
        rs.close();
        conn.close();
    %>
</body>
</html>
